﻿<%@ Page Title="New Customer" Language="C#" MasterPageFile="~/Pages/user/userMaster.Master" AutoEventWireup="true" CodeBehind="NewCustomer.aspx.cs" Inherits="WarehouseWebAPP.Pages.user.New_Entities.NewCustomer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style1">
        <tr>
            <td>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:DetailsView ID="CustomerDetailsView" runat="server" AllowPaging="True" 
                    AutoGenerateRows="False" CellPadding="4" DataKeyNames="customer_num" 
                    DataSourceID="CustomerObjectDataSource" DefaultMode="Insert" 
                    ForeColor="#333333" GridLines="None" Height="50px" 
    Width="436px">
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <Fields>
                                <asp:BoundField DataField="customer_num" HeaderText="customer_num" 
                            ReadOnly="True" SortExpression="customer_num" Visible="False" />
                                <asp:TemplateField HeaderText="Customer ID No." SortExpression="customer_id">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("customer_id") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("customer_id") %>' 
                                    ToolTip="9 Digits."></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                    ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                                    ErrorMessage="Invalid ID." ToolTip="9 Digits." 
                                    ValidationExpression="\d{9}" ControlToValidate="TextBox1"></asp:RegularExpressionValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("customer_id") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Customer Name" SortExpression="customer_name">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("customer_name") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("customer_name") %>'></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                    ControlToValidate="TextBox2" ErrorMessage="*"></asp:RequiredFieldValidator>
                                        <asp:CustomValidator ID="CustomValidator2" runat="server" 
                                    ControlToValidate="TextBox2" ErrorMessage="Already Exist." 
                                    onservervalidate="CustomValidator2_ServerValidate"></asp:CustomValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("customer_name") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Customer Type" SortExpression="customer_type">
                                    <EditItemTemplate>
                                        <asp:DropDownList ID="DropDownList1" runat="server" 
                                    DataSourceID="TypeObjectDataSource" DataTextField="customer_type" 
                                    DataValueField="customer_type_num" 
                                    SelectedValue='<%# Bind("customer_type") %>'>
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="TypeObjectDataSource" runat="server" 
                                    InsertMethod="CustomerTypeInsert" SelectMethod="CustomerTypeGet" 
                                    TypeName="WarehouseWebAPP.code.BLL.CustomerTypeBLL">
                                            <InsertParameters>
                                                <asp:Parameter Name="customer_type" Type="String" />
                                            </InsertParameters>
                                        </asp:ObjectDataSource>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:DropDownList ID="DropDownList1" runat="server" 
                                    DataSourceID="TypeObjectDataSource" DataTextField="customer_type" 
                                    DataValueField="customer_type_num" 
                                    SelectedValue='<%# Bind("customer_type") %>'>
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="TypeObjectDataSource" runat="server" 
                                    InsertMethod="CustomerTypeInsert" OldValuesParameterFormatString="original_{0}" 
                                    SelectMethod="CustomerTypeGet" 
                                    TypeName="WarehouseWebAPP.code.BLL.CustomerTypeBLL">
                                            <InsertParameters>
                                                <asp:Parameter Name="customer_type" Type="String" />
                                            </InsertParameters>
                                        </asp:ObjectDataSource>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="TypeLabel" runat="server" Text='<%# Bind("customer_type") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="customer_address" HeaderText="Address" 
                            SortExpression="customer_address" />
                                <asp:TemplateField HeaderText="Phone No." SortExpression="customer_phone">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("customer_phone") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("customer_phone") %>'></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                    ControlToValidate="TextBox4" ErrorMessage="*"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                    ControlToValidate="TextBox4" ErrorMessage="Invalid Phone No." 
                                    
                                    
                                    
                                            ValidationExpression="^0[23489]{1}(\-)?[^0\D]{1}\d{6}$|^0(5[012345678]){1}(\-)?\d{7}$"></asp:RegularExpressionValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("customer_phone") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="E-mail Address" SortExpression="customer_email">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("customer_email") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("customer_email") %>'></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                    ControlToValidate="TextBox3" ErrorMessage="*"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                    ControlToValidate="TextBox3" ErrorMessage="Invalid Email" 
                                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("customer_email") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:CommandField ShowInsertButton="True" />
                            </Fields>
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#999999" />
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        </asp:DetailsView>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server" 
                    InsertMethod="CustomerInsert" SelectMethod="CustomerGet" 
                    TypeName="WarehouseWebAPP.code.BLL.CustomerBLL">
                    <InsertParameters>
                        <asp:Parameter Name="customer_id" Type="String" />
                        <asp:Parameter Name="customer_name" Type="String" />
                        <asp:Parameter Name="customer_type" Type="String" />
                        <asp:Parameter Name="customer_address" Type="String" />
                        <asp:Parameter Name="customer_phone" Type="String" />
                        <asp:Parameter Name="customer_email" Type="String" />
                    </InsertParameters>
                </asp:ObjectDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
